package com.kl.controller;


import com.alibaba.fastjson.JSONObject;
import com.kl.domain.CollectionDTO;
import com.kl.domain.InvoiceDTO;
import com.kl.em.ConstantEnum;
import com.kl.em.Result;
import com.kl.entity.Collection;
import com.kl.entity.Invoice;
import com.kl.service.IInvoiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2021-10-30
 */
@RestController
@RequestMapping("/invoice")//发票
@Api(value = "发票表管理接口")
public class InvoiceController {
    @Autowired
    private IInvoiceService iInvoiceService;
    @ApiOperation(value = "增加代收货款详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "invoiceDTO", value = "实体类", required = true, paramType = "body")
    })
    @PostMapping
    public Result add(@RequestBody InvoiceDTO invoiceDTO) {
        //FreightDTO dto = new FreightDTO();
        // freightServiceFeign.add(dto);
        String s = JSONObject.toJSONString(invoiceDTO);
        Invoice freight = JSONObject.parseObject(s, Invoice.class);
        iInvoiceService.save(freight);
        return Result.build(ConstantEnum.SUCCESS);
    }
}
